Create a UnitOfWork service that wraps dataSource.transaction() and provides per-type repositories from the transactional EntityManager. The calling service receives a repos object containing all repositories bound to the same transaction, eliminating the need to manually thread EntityManager through every method call.
Groups all repositories under a single shared transaction without threading EntityManager manually.
The work callback receives repository instances already bound to the transactional manager.
Add new entity types to the repos parameter as the domain grows — no service changes required.
All writes commit atomically or roll back together — no partial state is ever persisted.
Services remain focused on business logic; transaction infrastructure is fully encapsulated in UnitOfWork.